<?php
/**===========================================================================================
# mod_otminislideshow   OT Mini Slideshow Module For Joomla 1.7.0
#=============================================================================================
# author                OmegaTheme.com
# copyright             Copyright (C) 2011 OmegaTheme.com. All rights reserved.
# @license              http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
# Website               http://omegatheme.com
# Technical support     Forum - http://omegatheme.com/forum/
#=============================================================================================*/

/**--------------------------------------------------------------------------------------------
* file:           tmpl/default.php 1.7.0 00002, 12 Dec 2011 15:00:00Z OmegaTheme:Linh $
* package:        OT Mini Slideshow module
* description:    default layout file
*---------------------------------------------------------------------------------------------*/

defined('_JEXEC') or die('Restricted access');

if (!function_exists('randomkeys')) {
	function randomkeys($length) {
		$pattern = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
		$key = '';
		for($i = 0; $i < $length; $i++)	{
			$key .= $pattern{rand(0,strlen($pattern)-1)};
		}
		return $key;
	}
}
$rid = randomkeys(16);
$show_readmore = $params->get('show_readmore', 0);
$show_link = $params->get('show_link', 1);
$panel_width = $params->get('panel_width', 900);
$panel_height = $params->get('panel_height', 300);
$overlay_position = $params->get('overlay_position', 'bottom');
$overlay_height = $params->get('overlay_height', 75);
$overlay_width = $params->get('overlay_width', 250);
$overlay_color = $params->get('overlay_color', '#000000');
$overlay_opacity = $params->get('overlay_opacity', 0.6);
$overlay_text_color = $params->get('overlay_text_color', '#FFFFFF');
$overlay_font_size = $params->get('overlay_font_size', '12px');
$overlay_heading_color = $params->get('overlay_heading_color', '#FDDE11');
$show_control = $params->get('show_control', 0) == 1 ? 'true' : 'false';
$show_toc = $params->get('show_toc', 1) == 1 ? 'true' : 'false';
$display_duration = $params->get('display_duration', 4000);
$overlay_link_color = $params->get('overlay_link_color', '#FDDE11');

$overlay_top = ($overlay_position=='top'?'0':($overlay_position=='bottom'?($panel_height-$overlay_height):(($panel_height-$overlay_height)/2)));
$overlay_left = (($overlay_position=='top' || $overlay_position=='bottom')?'0':($overlay_position=='left'?'0':($panel_width-$overlay_width)));
$ie_overlay_opacity = $overlay_opacity*100;
$control_top = ($panel_height-32)/2;

$style = "
	.overlay_bg, .overlay_text {
		width: {$overlay_width}px;
		height: {$overlay_height}px;
		top: {$overlay_top}px;
		left: {$overlay_left}px;
	}
	.overlay_bg {
		background: {$overlay_color};
		filter: alpha(opacity = {$ie_overlay_opacity});
		-moz-opacity: {$overlay_opacity};
		-khtml-opacity: {$overlay_opacity};
		opacity: {$overlay_opacity};
	}
	#next,#previous {
		top: {$control_top}px;
		outline: none;
	}
";
$doc->addStyleDeclaration($style);
?>
<div class="mss-wrapper">
	<div id="mss_<?php echo $rid; ?>" style="position: relative; z-index: 1; width:<?php echo $panel_width; ?>px; height:<?php echo $panel_height; ?>px;">
        <?php if (count($list) > 0 ): ?>
		<?php foreach ($list as $item) : ?>
			<div class="article-slide-i_<?php echo $rid; ?>" style="position:absolute; z-index: 1; top: 0; left: 0; display:block; width:<?php echo $panel_width; ?>px; height:<?php echo $panel_height; ?>px;">
				<img src="<?php echo $item->images;?>" width="<?php echo $panel_width;?>" height="<?php echo $panel_height;?>" alt="<?php echo $item->title;?>" />
				<div class="overlay_bg"></div>
				<div class="overlay_text">
					<div class="overlay_text_inner">
						<h3 class="title" style="color:<?php echo $overlay_heading_color ?>; margin: 5px 0 10px">
							<?php if($show_link == 1){?>
								<a href="<?php echo $item->link?>" style="color:<?php echo $overlay_heading_color ?>"><?php echo $item->title?></a><br/>
							<?php }else{?>
								<span><?php echo $item->title;?></span>
							<?php }?>
						</h3>
						<p class="introtext" style="color:<?php echo $overlay_text_color ?>"><?php echo $item->mini_introtext.'...';?></p>
						<?php 
							if($show_readmore == 1){
								echo '<a style="color:'.$overlay_link_color.'" class="readmore" href = "' .$item->link. '" title="'.$item->title.'">'.JText::_('READMORE').'</a>' ; 
							}
						?>
					</div>
				</div>
			</div>
		<?php endforeach; ?>
        <div id="tc_<?php echo $rid; ?>" class="toc_container"></div>
        <?php else: ?>
        <p>There is no article to show!</p>
        <?php endif; ?>
	</div>
</div>
<div class="ot-mini-slideshow"><?php echo JText::_('ABOUT_OT_MINI_SLIDESHOW'); ?></div>
<script type="text/javascript" src="<?php echo JURI::root()?>modules/mod_otminislideshow/js/otmss_moo13.js"></script>
<?php if (count($list) > 0 ): ?>
<script type="text/javascript" charset="utf-8">
<!--
/* start slideshow when page loaded */
window.addEvent('domready',function() {
	var options = new Object({
		showControls: <?php echo $show_control ?>,
		showDuration: <?php echo $display_duration ?>,
		showToc: <?php echo $show_toc ?>,
        tocRanId: "<?php echo $rid; ?>"
	});
	var mss_slideshow_<?php echo $rid; ?> = new MSS('mss_<?php echo $rid; ?>','.article-slide-i_<?php echo $rid; ?>', options);
	//start
	mss_slideshow_<?php echo $rid; ?>.mstart();
});
// -->
</script>
<?php endif; ?>
